package com.xxx.dao.impl;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.xxx.bean.SC_User;
import com.xxx.dao.SC_UserDAO;

public class SC_UserDaoImpl extends HibernateDaoSupport implements SC_UserDAO{

	public void delete(SC_User user) throws Exception{
	
		getHibernateTemplate().delete(user);
		
	}

	public void save(SC_User user) throws Exception{
		
		getHibernateTemplate().save(user);

	}

	public void update(SC_User user) throws Exception{

        getHibernateTemplate().update(user);
		
	}

	public SC_User getByUnoAndPwd(int uno, String upassword) throws Exception {
		String hql="FROM SC_User WHERE sno=? and upassword=?";
		Object[] value={uno,upassword};
		SC_User user=null;
		List<SC_User>list=getHibernateTemplate().find(hql, value);
		if(list.isEmpty()){
			return user;
		}else{
			user=list.get(0);
		}
		
		    return user;
	}
	


	public List<SC_User> findAll() throws Exception {

          String hql="FROM SC_User";
          List<SC_User> scuserList=getHibernateTemplate().find(hql);
		  return scuserList;
	}

	public SC_User findByUno(int uno) throws Exception {
		 String hql="FROM SC_User where sno=?";
         SC_User scuser=(SC_User)getHibernateTemplate().find(hql,uno).get(0);
		return scuser;
	}
	

}
